<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
<!--        <div class="layui-inline" style="padding-left: 5px;">-->
<!--            <select name="user_status" >-->
<!--                <option value="">Please User Status</option>-->
<!--                <option value="1">正常</option>-->
<!--                <option value="2">停用</option>-->
<!--            </select>-->
<!--        </div>-->
        <div class="layui-inline">
            <input type="text" name="username" lay-verify="title" style="width:250px;"
                   class="layui-input" placeholder="Username">
        </div>
        <div class="layui-inline">
            <input type="text" name="session_id" lay-verify="title" style="width:300px;"
                   class="layui-input" placeholder="session_id">
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var table   = layui.table;
        var form    = layui.form;

        var tableIn =layui.table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            url: "{:url('veriffCheck')}",
            id: 'balanceTable',
            // toolbar: '#toolbar',
            totalRow: true,
            cols: [[
                { type: 'numbers'},
                { field: 'username', align: 'left', title: '用户' ,width:250},
                { field: 'session_id', align: 'left', title: 'SessionID' ,width:300},
                { field: 'is_rep', align: 'right', title: '状态' ,width:150},
                { field: 'name', align: 'right', title: 'name' ,width:120},
                { field: 'option', title: 'Action',width:120,
                    templet: function (d) {
                        const is_rep = d.is_rep;
                        if(is_rep === null){
                            var html = '<a class="layui-btn layui-btn-xs editVeriff" data-id="' + d.id + '">编辑</a>';
                        }else{
                            var html = '--';
                        }
                        return html;
                    }, align: 'center'
                },
                { field: 'time', align: 'center', title: 'Time' , width: 160,
                    templet: function (d) {
                        return layui.util.toDateString(d.time * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                },
                { field: 'id_number', align: 'right', title: '身份证编码' ,width:150},
                { field: 'remark', align: 'right', title: 'remark' ,width:200},
                // { field: 'status', title: '状态', width:100 ,
                //     templet:function (d) {
                //         const status=   d.status;
                //         var   html  =   '';
                //         switch (status) {
                //             case 1:
                //                 html = "<span style='color: green'>正常</span>";
                //                 break;
                //             case 2:
                //                 html = "<span style='color: #ff0000'>停用</span>";
                //                 break;
                //         }
                //         return html;
                //     }
                // },
            ]],
            page: true,
            limit: 1000,
            limits: [1000],
        });

        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        $(document).on('click', '.editVeriff', function () {
            var id = $(this).attr('data-id');
            JsGet("{:url('user/editVeriff')}?v_id="+id, function(e){
                if(e.status == 1){
                    layer.open({
                        type: 1,
                        title: 'Veriff Edit',
                        area: ['550px', '400px'], //宽高
                        content: e.datas,
                        btn:['Confirm','Close'],
                        yes:function (index,layero) {
                            var thedata = $('.operationForm').serialize();
                            JsPost('{:url("user/editVeriff")}', thedata,function (re) {
                                if(re.code >0){
                                    layer.msg(re.msg , {icon:1,time:1500});
                                    layer.close(index);
                                    tableIn.reload({
                                        page:{
                                            curr :1
                                        }
                                    });
                                }else{
                                    layer.msg(re.msg, {icon:2,time:1500});
                                }
                            });
                        }
                    });
                }else{
                    layer.msg(e.msg);
                }
            });
        });
    });
</script>